#include <iostream>
#include <functional>
#include <vector>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>

using namespace std;

void Sched()
{
    cout << "进程调度" << endl;
}

void MemManger()
{
    cout << "内存管理" << endl;
}

void Fflush()
{
    cout << "刷新程序" << endl;
}

using func_t = function<void()>;

vector<func_t> funcs;
 
void myAlarm(int sig)
{
    //cout << "get a siganl: " << sig << endl;
    cout << "###########################" << endl;
    for(auto func : funcs)
    {
        func();
    }
    cout << "###########################" << endl;   
    alarm(1);
}

int main()
{
    funcs.push_back(Sched); 
    funcs.push_back(MemManger);
    funcs.push_back(Fflush);

    signal(SIGALRM, myAlarm);
    alarm(1);

    while(1)
    {
        pause(); // 暂停只到收到一个信号
    }

    return 0;
}